package com.stlm2.dems.maintain.service;

import com.stlm2.util.Convert;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;

import com.stlm2.dems.maintain.entity.Maintain;
import com.stlm2.dems.maintain.dao.MaintainDao;
import com.stlm2.core.base.BaseDao;
import com.stlm2.core.base.impl.BaseServiceImpl;
import org.springframework.ui.ModelMap;

@Service("maintainService")
@Transactional(rollbackForClassName={"java.lang.Exception"}, propagation = Propagation.REQUIRED)
public class MaintainService extends BaseServiceImpl<Maintain> {

	@Resource
	private MaintainDao maintainDao;

	@Override
	protected BaseDao <Maintain> getDao() {
		return maintainDao;
	}

	public Maintain getLastVersion() {
		return maintainDao.getLastVersion();
	}

	public ModelMap buildModel(Maintain maintain) {
		ModelMap model = new ModelMap();
		model.put("remark",maintain.getRemark());
		model.put("versions",maintain.getVersions());
		model.put("beginTime", Convert.toYMDHMS(maintain.getBeginTime()));
		model.put("endTime",Convert.toYMDHMS(maintain.getEndTime()));
		return model;
	}
}